package po;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/11 16:12
 * @description:
 */
public class MyRedis {
  private JedisPool jedisPool;
 public MyRedis(JedisPool jedisPool)
 {
   this.jedisPool=jedisPool;
 }
 public void hset(String key,String field,String value)
 {
   Jedis jedis=null;
   try {
     Jedis con = this.jedisPool.getResource();
     con.hset(key,field,value);
   }
  finally {
     this.jedisPool.returnResource(jedis);
   }
 }
 public void hget(String key,String field)

 {
   Jedis jedis=null;
   try{
     Jedis  con= this.jedisPool.getResource();
     if(con.exists(key)) {
       String value = con.hget(key, field);
       System.out.println(value);
     }
     else
     {
       System.out.println("不存在所对应的值");
     }
   }
   finally {
     this.jedisPool.returnResource(jedis);
   }
 }

}
